namespace Maple.Branch.Settings.Providers
{
    using IServices;
    using Volo.Abp.DependencyInjection;
    using Volo.Abp.Settings;
    using Volo.Abp.Users;

    public class UserSettingProvider : BranchSettingProvider, ITransientDependency
    {
        public override string Name => UserSettingValueProvider.ProviderName;

        protected ICurrentUser CurrentUser { get; }

        public UserSettingProvider(
            IBranchSettingStore settingStore,
            ICurrentUser currentUser)
            : base(settingStore)
        {
            CurrentUser = currentUser;
        }

        protected override string NormalizeProviderKey(string providerKey)
        {
            if (providerKey != null)
            {
                return providerKey;
            }

            return CurrentUser.Id?.ToString();
        }
    }
}
